<?php

/**
 * KTDPlayer form base class.
 *
 * @method KTDPlayer getObject() Returns the current form's model object
 *
 * @package    s-test
 * @subpackage form
 * @author     Your name here
 * @version    SVN: $Id: sfDoctrineFormGeneratedTemplate.php 29553 2010-05-20 14:33:00Z Kris.Wallsmith $
 */
abstract class BaseKTDPlayerForm extends BaseFormDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'id'                   => new sfWidgetFormInputHidden(),
      'realname'             => new sfWidgetFormInputText(),
      'default_character_id' => new sfWidgetFormInputText(),
      'password'             => new sfWidgetFormInputText(),
      'pseudo'               => new sfWidgetFormInputText(),
      'email'                => new sfWidgetFormInputText(),
      'avatar'               => new sfWidgetFormInputText(),
      'signature'            => new sfWidgetFormInputText(),
      'quote'                => new sfWidgetFormInputText(),
      'title'                => new sfWidgetFormInputText(),
      'last_connexion'       => new sfWidgetFormDateTime(),
      'registered_at'        => new sfWidgetFormDateTime(),
    ));

    $this->setValidators(array(
      'id'                   => new sfValidatorChoice(array('choices' => array($this->getObject()->get('id')), 'empty_value' => $this->getObject()->get('id'), 'required' => false)),
      'realname'             => new sfValidatorString(array('max_length' => 255)),
      'default_character_id' => new sfValidatorInteger(array('required' => false)),
      'password'             => new sfValidatorString(array('max_length' => 255)),
      'pseudo'               => new sfValidatorString(array('max_length' => 255)),
      'email'                => new sfValidatorString(array('max_length' => 255)),
      'avatar'               => new sfValidatorString(array('max_length' => 255, 'required' => false)),
      'signature'            => new sfValidatorPass(array('required' => false)),
      'quote'                => new sfValidatorPass(array('required' => false)),
      'title'                => new sfValidatorString(array('max_length' => 255, 'required' => false)),
      'last_connexion'       => new sfValidatorDateTime(array('required' => false)),
      'registered_at'        => new sfValidatorDateTime(),
    ));

    $this->validatorSchema->setPostValidator(
      new sfValidatorAnd(array(
        new sfValidatorDoctrineUnique(array('model' => 'KTDPlayer', 'column' => array('realname'))),
        new sfValidatorDoctrineUnique(array('model' => 'KTDPlayer', 'column' => array('pseudo'))),
        new sfValidatorDoctrineUnique(array('model' => 'KTDPlayer', 'column' => array('email'))),
      ))
    );

    $this->widgetSchema->setNameFormat('ktd_player[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    $this->setupInheritance();

    parent::setup();
  }

  public function getModelName()
  {
    return 'KTDPlayer';
  }

}
